FROM ccr.ccs.tencentyun.com/yy-dk/hadoop:2.8.4

MAINTAINER Yang <yangyufans@qq.com>

ENV HIVE_VERSION 2.3.3
ENV HADOOP_VERSION 2.8.4
ENV HIVE_NAME apache-hive-2.3.3-bin

RUN cd / && wget http://mirror.bit.edu.cn/apache/hive/hive-$HIVE_VERSION/$HIVE_NAME.tar.gz \
 && tar -zvxf $HIVE_NAME.tar.gz  -C /usr/local/ \
 && rm -rf $HIVE_NAME.tar.gz \
 && mv /usr/local/$HIVE_NAME /usr/local/hive-$HIVE_VERSION

ENV HIVE_HOME "/usr/local/hive-$HIVE_VERSION"
ENV PATH "$PATH:$HIVE_HOME/bin"

RUN echo "export HIVE_HOME=/usr/local/hive-$HIVE_VERSION" >> /etc/profile && \
    echo 'export PATH=$PATH:$HIVE_HOME/bin' >> /etc/profile && \
    source /etc/profile

RUN cp $HIVE_HOME/conf/hive-env.sh.template $HIVE_HOME/conf/hive-env.sh && \
    echo "HADOOP_HOME=$HADOOP_HOME" >> $HIVE_HOME/conf/hive-env.sh && \
    echo "HADOOP_VERSION=$HADOOP_VERSION" >> $HIVE_HOME/conf/hive-env.sh && \
    cp $HIVE_HOME/conf/hive-log4j2.properties.template $HIVE_HOME/conf/hive-log4j2.properties && \
    sed -i 's/${sys:java.io.tmpdir}/\/logs/g' $HIVE_HOME/conf/hive-log4j2.properties && \
    sed -i 's/${sys:user.name}/hive/g' $HIVE_HOME/conf/hive-log4j2.properties

COPY conf/* $HIVE_HOME/conf/

COPY start.sh /

RUN chmod 777 /start.sh

EXPOSE 22 8020 8088 8042 9870

CMD ["/start.sh"]
